package tech.ezrealc.fall2023.model.personnel.student.mapper;

import org.mapstruct.*;
import tech.ezrealc.fall2023.model.personnel.student.StudentDO;
import tech.ezrealc.fall2023.model.personnel.student.StudentDTO;
import tech.ezrealc.fall2023.model.personnel.student.StudentVO;
import tech.ezrealc.fall2023.model.user.UserDO;

import java.util.List;
import java.util.Objects;

@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface StudentMapper {

    List<StudentDTO> toDTOList(List<StudentDO> studentDOList);

    @IterableMapping(qualifiedByName = "DTOtoVO")
    List<StudentVO> toVOList(List<StudentDTO> studentDTOList);

    @Named("DTOtoVO")
    default StudentVO mappingName(StudentDTO studentDTO){
        StudentDO studentDO = studentDTO.getStudentDO();
        UserDO userDO = studentDTO.getUserDO();
        StudentVO studentVO = new StudentVO();
        studentVO.setId(studentDO.getId());
        studentVO.setGender(studentDO.getGender());
        studentVO.setBirthday(studentDO.getBirthday());
        studentVO.setSchoolId(studentDO.getSchoolId());
        studentVO.setDepartment(studentDO.getDepartment());
        studentVO.setMajor(studentDO.getMajor());
        studentVO.setClasse(studentDO.getClasse());
        studentVO.setBatch(studentDO.getBatch());
        studentVO.setName(userDO.getName());
        return studentVO;
    }

}
